package co.fitstart.entity.courseware.assessment;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import co.fitstart.entity.course.round.CourseRound;

/**
 * 学员评估-体态关节
 * @author haiyan_xiao
 *
 */
@Entity
@Table(name = "posture_joint")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class PostureJoint {
    @Id
    @GeneratedValue
    private Long id;
    
    /** 所属课次 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JSONField(serialize = false)
    private CourseRound courseRound;
    
    /** 静态正面站姿-头部 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForThreeOptions obverseHead;
    
    /** 静态正面站姿-肩胛骨 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForTwoOptions obverseScapula;
    
    /** 静态正面站姿-骨盆 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForThreeOptions obversePelvis;
    
    /** 静态正面站姿-膝关节 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForThreeOptions obverseKneeJoint;
    
    /** 静态背面站姿-头部 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForTwoOptions reverseHead;
    
    /** 静态背面站姿-颈椎 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForTwoOptions reverseCervicalVertebra;
    
    /** 静态背面站姿-髋关节 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForThreeOptions reverseHipJoint;
    
    /** 静态背面站姿-膝关节 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForTwoOptions reverseKneeJoint;
    
    /** 静态背面站姿-足部 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForTwoOptions reverseFoot;
    
    /** 膝盖伸展方向 */
    @Enumerated(EnumType.ORDINAL)
    private PostureForThreeOptions kneeDirection;
    
    /** 上半身与小腿是否平行 */
    private Boolean parallel;
    
    /** 关节-胸椎 */
    @Enumerated(EnumType.ORDINAL)
    private JointStatus thoracicVertebra;
    
    /** 关节-腿后侧肌群 */
    @Enumerated(EnumType.ORDINAL)
    private JointStatus legMuscle;
    
    /** 关节-髋关节 */
    @Enumerated(EnumType.ORDINAL)
    private JointStatus hipJoint;
    
    /** 关节-肩关节 */
    @Enumerated(EnumType.ORDINAL)
    private JointStatus shoulderJoint;
    
    /** 关节-踝关节 */
    @Enumerated(EnumType.ORDINAL)
    private JointStatus ankleJoint;
    
    /** 关节-其他 */
    private String jointRemark;
    
    /** 体态总结 */
    private String postureSummary;
    
    /** 关节总结 */
    private String jointSummary;
    
    /** 总结 */
    private String summary;
    
    private Date createTime;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    public PostureJoint() {
        
    }
    
    public PostureJoint(CourseRound courseRound) {
        this.courseRound = courseRound;
        this.createTime = new Date();
        this.disabled = false;
    }
    
    /**
     * initialize
     * @param courseRound
     * @return
     */
    public PostureJoint initialize(CourseRound courseRound) {
        this.courseRound = courseRound;
        this.createTime = new Date();
        this.disabled = false;
        
        return this;
    }
    
    /**
     * edit
     * @param postureJoint
     * @return
     */
    public PostureJoint edit(PostureJoint postureJoint) {
        this.obverseHead = postureJoint.getObverseHead();
        this.obverseScapula = postureJoint.getObverseScapula();
        this.obversePelvis = postureJoint.getObversePelvis();
        this.obverseKneeJoint = postureJoint.getObverseKneeJoint();
        this.reverseHead = postureJoint.getReverseHead();
        this.reverseCervicalVertebra = postureJoint.getReverseCervicalVertebra();
        this.reverseHipJoint = postureJoint.getReverseHipJoint();
        this.reverseKneeJoint = postureJoint.getReverseKneeJoint();
        this.reverseFoot = postureJoint.getReverseFoot();
        this.kneeDirection = postureJoint.getKneeDirection();
        this.parallel = postureJoint.getParallel();
        this.thoracicVertebra = postureJoint.getThoracicVertebra();
        this.legMuscle = postureJoint.getLegMuscle();
        this.hipJoint = postureJoint.getHipJoint();
        this.shoulderJoint = postureJoint.getShoulderJoint();
        this.ankleJoint = postureJoint.getAnkleJoint();
        this.jointRemark = postureJoint.getJointRemark();
        
        return this;
    }
    
    /**
     * edit
     * @param postureSummary
     * @param jointSummary
     * @param summary
     * @return
     */
    public PostureJoint edit(String postureSummary, String jointSummary, String summary) {
        this.postureSummary = postureSummary;
        this.jointSummary = jointSummary;
        this.summary = summary;
        
        return this;
    }

    public boolean isShow() {
        return this.isShowPosture() || this.isShowJoint();
    }

    public boolean isShowPosture() {
        return this.isShowObversePosture() || this.isShowReversePosture() || this.isShowSquat();
    }

    public boolean isShowObversePosture() {
        return this.obverseHead != null || this.obverseScapula != null || this.obversePelvis != null || this.obverseKneeJoint != null;
    }

    public boolean isShowReversePosture() {
        return this.reverseHead != null || this.reverseCervicalVertebra != null || this.reverseHipJoint != null || this.reverseKneeJoint != null || this.reverseFoot != null;
    }

    public boolean isShowSquat() {
        return this.kneeDirection != null || this.parallel != null;
    }

    public boolean isShowJoint() {
        return this.thoracicVertebra != null || this.legMuscle != null || this.hipJoint != null || this.shoulderJoint != null || this.ankleJoint != null;
    }

    public String getObverseHeadDesc() {
        return this.obverseHead == null ? null : this.obverseHead.getHead();
    }

    public String getObverseScapulaDesc() {
        return this.obverseScapula == null ? null : this.obverseScapula.getScapula();
    }

    public String getObversePelvisDesc() {
        return this.obversePelvis == null ? null : this.obversePelvis.getPelvis();
    }

    public String getObverseKneeJointDesc() {
        return this.obverseKneeJoint == null ? null : this.obverseKneeJoint.getKneeJoint();
    }

    public String getReverseHeadDesc() {
        return this.reverseHead == null ? null : this.reverseHead.getHead();
    }

    public String getReverseCervicalVertebraDesc() {
        return this.reverseCervicalVertebra == null ? null : this.reverseCervicalVertebra.getCervicalVertebra();
    }

    public String getReverseHipJointDesc() {
        return this.reverseHipJoint == null ? null : this.reverseHipJoint.getHipJoint();
    }

    public String getReverseKneeJointDesc() {
        return this.reverseKneeJoint == null ? null : this.reverseKneeJoint.getKneeJoint();
    }

    public String getReverseFootDesc() {
        return this.reverseFoot == null ? null : this.reverseFoot.getFoot();
    }

    public String getKneeDirectionDesc() {
        return this.kneeDirection == null ? null : this.kneeDirection.getKneeDirection();
    }

    public String getParallelDesc() {
        return this.parallel == null ? null : (this.parallel ? "是" : "否");
    }

    public String getThoracicVertebraDesc() {
        return this.thoracicVertebra == null ? null : thoracicVertebra.getDescription();
    }

    public String getLegMuscleDesc() {
        return this.legMuscle == null ? null : this.legMuscle.getDescription();
    }

    public String getHipJointDesc() {
        return this.hipJoint == null ? null : this.hipJoint.getDescription();
    }

    public String getShoulderJointDesc() {
        return this.shoulderJoint == null ? null : this.shoulderJoint.getDescription();
    }

    public String getAnkleJointDesc() {
        return this.ankleJoint == null ? null : this.ankleJoint.getDescription();
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the courseRound
     */
    public CourseRound getCourseRound() {
        return courseRound;
    }

    /**
     * @return the obverseHead
     */
    public PostureForThreeOptions getObverseHead() {
        return obverseHead;
    }

    /**
     * @return the obverseScapula
     */
    public PostureForTwoOptions getObverseScapula() {
        return obverseScapula;
    }

    /**
     * @return the obversePelvis
     */
    public PostureForThreeOptions getObversePelvis() {
        return obversePelvis;
    }

    /**
     * @return the obverseKneeJoint
     */
    public PostureForThreeOptions getObverseKneeJoint() {
        return obverseKneeJoint;
    }

    /**
     * @return the reverseHead
     */
    public PostureForTwoOptions getReverseHead() {
        return reverseHead;
    }

    /**
     * @return the reverseCervicalVertebra
     */
    public PostureForTwoOptions getReverseCervicalVertebra() {
        return reverseCervicalVertebra;
    }

    /**
     * @return the reverseHipJoint
     */
    public PostureForThreeOptions getReverseHipJoint() {
        return reverseHipJoint;
    }

    /**
     * @return the reverseKneeJoint
     */
    public PostureForTwoOptions getReverseKneeJoint() {
        return reverseKneeJoint;
    }

    /**
     * @return the reverseFoot
     */
    public PostureForTwoOptions getReverseFoot() {
        return reverseFoot;
    }

    /**
     * @return the kneeDirection
     */
    public PostureForThreeOptions getKneeDirection() {
        return kneeDirection;
    }

    /**
     * @return the parallel
     */
    public Boolean getParallel() {
        return parallel;
    }

    /**
     * @return the thoracicVertebra
     */
    public JointStatus getThoracicVertebra() {
        return thoracicVertebra;
    }

    /**
     * @return the legMuscle
     */
    public JointStatus getLegMuscle() {
        return legMuscle;
    }

    /**
     * @return the hipJoint
     */
    public JointStatus getHipJoint() {
        return hipJoint;
    }

    /**
     * @return the shoulderJoint
     */
    public JointStatus getShoulderJoint() {
        return shoulderJoint;
    }

    /**
     * @return the ankleJoint
     */
    public JointStatus getAnkleJoint() {
        return ankleJoint;
    }

    /**
     * @return the jointRemark
     */
    public String getJointRemark() {
        return jointRemark;
    }

    /**
     * @return the postureSummary
     */
    public String getPostureSummary() {
        return postureSummary;
    }

    /**
     * @return the jointSummary
     */
    public String getJointSummary() {
        return jointSummary;
    }

    /**
     * @return the summary
     */
    public String getSummary() {
        return summary;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param courseRound the courseRound to set
     */
    public void setCourseRound(CourseRound courseRound) {
        this.courseRound = courseRound;
    }

    /**
     * @param obverseHead the obverseHead to set
     */
    public void setObverseHead(PostureForThreeOptions obverseHead) {
        this.obverseHead = obverseHead;
    }

    /**
     * @param obverseScapula the obverseScapula to set
     */
    public void setObverseScapula(PostureForTwoOptions obverseScapula) {
        this.obverseScapula = obverseScapula;
    }

    /**
     * @param obversePelvis the obversePelvis to set
     */
    public void setObversePelvis(PostureForThreeOptions obversePelvis) {
        this.obversePelvis = obversePelvis;
    }

    /**
     * @param obverseKneeJoint the obverseKneeJoint to set
     */
    public void setObverseKneeJoint(PostureForThreeOptions obverseKneeJoint) {
        this.obverseKneeJoint = obverseKneeJoint;
    }

    /**
     * @param reverseHead the reverseHead to set
     */
    public void setReverseHead(PostureForTwoOptions reverseHead) {
        this.reverseHead = reverseHead;
    }

    /**
     * @param reverseCervicalVertebra the reverseCervicalVertebra to set
     */
    public void setReverseCervicalVertebra(PostureForTwoOptions reverseCervicalVertebra) {
        this.reverseCervicalVertebra = reverseCervicalVertebra;
    }

    /**
     * @param reverseHipJoint the reverseHipJoint to set
     */
    public void setReverseHipJoint(PostureForThreeOptions reverseHipJoint) {
        this.reverseHipJoint = reverseHipJoint;
    }

    /**
     * @param reverseKneeJoint the reverseKneeJoint to set
     */
    public void setReverseKneeJoint(PostureForTwoOptions reverseKneeJoint) {
        this.reverseKneeJoint = reverseKneeJoint;
    }

    /**
     * @param reverseFoot the reverseFoot to set
     */
    public void setReverseFoot(PostureForTwoOptions reverseFoot) {
        this.reverseFoot = reverseFoot;
    }

    /**
     * @param kneeDirection the kneeDirection to set
     */
    public void setKneeDirection(PostureForThreeOptions kneeDirection) {
        this.kneeDirection = kneeDirection;
    }

    /**
     * @param parallel the parallel to set
     */
    public void setParallel(Boolean parallel) {
        this.parallel = parallel;
    }

    /**
     * @param thoracicVertebra the thoracicVertebra to set
     */
    public void setThoracicVertebra(JointStatus thoracicVertebra) {
        this.thoracicVertebra = thoracicVertebra;
    }

    /**
     * @param legMuscle the legMuscle to set
     */
    public void setLegMuscle(JointStatus legMuscle) {
        this.legMuscle = legMuscle;
    }

    /**
     * @param hipJoint the hipJoint to set
     */
    public void setHipJoint(JointStatus hipJoint) {
        this.hipJoint = hipJoint;
    }

    /**
     * @param shoulderJoint the shoulderJoint to set
     */
    public void setShoulderJoint(JointStatus shoulderJoint) {
        this.shoulderJoint = shoulderJoint;
    }

    /**
     * @param ankleJoint the ankleJoint to set
     */
    public void setAnkleJoint(JointStatus ankleJoint) {
        this.ankleJoint = ankleJoint;
    }

    /**
     * @param jointRemark the jointRemark to set
     */
    public void setJointRemark(String jointRemark) {
        this.jointRemark = jointRemark;
    }

    /**
     * @param postureSummary the postureSummary to set
     */
    public void setPostureSummary(String postureSummary) {
        this.postureSummary = postureSummary;
    }

    /**
     * @param jointSummary the jointSummary to set
     */
    public void setJointSummary(String jointSummary) {
        this.jointSummary = jointSummary;
    }

    /**
     * @param summary the summary to set
     */
    public void setSummary(String summary) {
        this.summary = summary;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}
